import java.io.IOException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-05-27
 * Time: 17:32
 */
public class TcpDicSever extends TcpEchoSever{
    // 使用继承可以复用之前的代码
    HashMap<String,String> map = new HashMap<>();
    public TcpDicSever(int port) throws IOException {
        super(port);
        map.put("cat","猫");
        map.put("dog","狗");
        map.put("fuck","我擦");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"Sorry该单词未找到！");
    }

    public static void main(String[] args) throws IOException {
        TcpDicSever tcpDicSever = new TcpDicSever(9090);
        tcpDicSever.start();
    }
}
